package com.changgou.goods.controller;
import com.changgou.entity.PageResult;
import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.goods.service.SpecService;
import com.changgou.goods.pojo.Spec;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@CrossOrigin
@RequestMapping("/spec")
public class SpecController {


    @Autowired
    private SpecService specService;

    @GetMapping("/add")
    public Result specsName(@RequestBody(required = false) Spec spec){
        specService.SpecName(spec);
        return new Result(true, StatusCode.OK,"查询成功",null);
    }

    @PostMapping("/{id}")
    public Result specsName(@PathVariable int id){
        specService.SpecDeleteId(id);
        return new Result(true, StatusCode.OK,"删除成功",null);
    }
    @GetMapping("/specs/{page}/{size}")
    public Result PageSpecs(@PathVariable int page,@PathVariable int size){
        Page<Spec> specsList = specService.pageSpec(page, size);
        return new Result(true, StatusCode.OK,"查询成功",specsList);
    }
}
